package cn.huhaoran.yaoyaolingxian.config;

import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;

/**
 * 新配置也持久化
 *
 * @author huhaoran
 * @date 2024-07-13
 */
@State(name = "NewPageAndViewModel", storages = {@Storage(value = "new-page-and-view-model.xml")})
public class NewPageAndViewModel implements PersistentStateComponent<NewPageAndViewModel> {

    private String jsonPath;

    private String enumPath;

    private String enumName;

    private HashMap<String,Boolean> checkBoxMap;

    public static NewPageAndViewModel getInstance(Project project) {
        return project.getService(NewPageAndViewModel.class);
    }

    @Override
    public @Nullable NewPageAndViewModel getState() {
        return this;
    }

    @Override
    public void loadState(@NotNull NewPageAndViewModel state) {
        this.jsonPath = state.jsonPath;
        this.enumPath = state.enumPath;
        this.enumName = state.enumName;
        this.checkBoxMap = state.checkBoxMap;
    }

    public HashMap<String, Boolean> getCheckBoxMap() {
        return checkBoxMap;
    }

    public void setCheckBoxMap(HashMap<String, Boolean> checkBoxMap) {
        this.checkBoxMap = checkBoxMap;
    }

    public String getJsonPath() {
        return jsonPath;
    }

    public void setJsonPath(String jsonPath) {
        this.jsonPath = jsonPath;
    }

    public String getEnumPath() {
        return enumPath;
    }

    public void setEnumPath(String enumPath) {
        this.enumPath = enumPath;
    }

    public String getEnumName() {
        return enumName;
    }

    public void setEnumName(String enumName) {
        this.enumName = enumName;
    }
}
